﻿#region Copyrights Notice
//©2010 Microsoft Corporation. All rights reserved.
#endregion

#region usings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web;
using System.Web.Caching;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;

using Microsoft.InformationSecurity.CISF.SecurityPortal.Services.Contracts;
#endregion

namespace Microsoft.InformationSecurity.CISF.SecurityPortal.Services
{
        /// <summary>
    /// Implementation for Portal Service Interface
    /// </summary>
    
    [ServiceContract] 
    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class PortalClientService
    {
        String _UserName;
        
        public PortalClientService()
        {
            _UserName = Environment.UserName;
        }

        #region Portal Client Methods
        [OperationContract]
        public string GetSelectedMenuItemFromCache()
        {
            if (HttpRuntime.Cache["SelectedMenuItem_" + _UserName] != null)
                return HttpRuntime.Cache["SelectedMenuItem_" + _UserName].ToString();

            return "";
        }

        [OperationContract]
        public bool PutSelectedMenuItemInCache(string val)
        {
            if (HttpRuntime.Cache["SelectedMenuItem_" + _UserName] != null)
                HttpRuntime.Cache.Remove("SelectedMenuItem_" + _UserName);

            HttpRuntime.Cache.Insert("SelectedMenuItem_" + _UserName, val, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(5));

            return true;
        }
        # endregion

    }
}
